import Vue from 'vue'
import Vuex from 'vuex'

import user from './module/user'
import app from './module/app'

import $localStore from 'store'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    //
    locale: $localStore.get('locale') || 'zh-cn',
    publicSideMenu: [],
  },
  mutations: {
    //
    SETLOCALE(state, locale) {
      $localStore.set('locale', locale);
      state.locale = locale;
    },
    SETPUBLICSIDEMENU(state, publicSideMenu) {
      state.publicSideMenu = publicSideMenu;
    },
    SETTOKEN(state, token) {
      state.token = token;
    },
  },
  getters: {
    getLocale: state => state.locale,
    getPublicSideMenu: state => state.publicSideMenu,
  },
  actions: {
    //
  },
  modules: {
    user,
    app
  }
})
